package main

import (
	"context"
	"time"

	"github.com/gorilla-go/pig"
	"github.com/gorilla-go/pig/middleware/io"
	"github.com/gorilla-go/pig/middleware/session"
)

func main() {
	r := pig.NewRouter()
	r.Any("/session", func(ctx context.Context) {
		duration, _ := time.ParseDuration("30m")
		response := io.GetOutput(ctx)
		response.SetCookieKV("yid", "222", duration)
		response.SetHeader("X-Track-ID", "123")
		response.Echo([]byte("ok"))
	})
	pig.NewServer().Router(r).Use(io.InputFormatter, io.OutputFormatter, session.SessionManager).Run(":8081")
}
